home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performBlendShapeRemove.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  10.5 KB  |  428 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  24 April 1997
  22. //
  23. //  Description:
  24. //      This script provides an option box dialog for the blendShape command.
  25. //
  26. //  Input Arguments:
  27. //        boolean showOptionBox    true - show the option box dialog
  28. //                                false - just execute the command
  29. //
  30. //  Return Value:
  31. //      None.
  32. //
  33.  
  34. //
  35. //  Procedure Name:
  36. //      setOptionVars
  37. //
  38. //  Description:
  39. //        Initialize the option values.
  40. //
  41. //  Input Arguments:
  42. //        Whether to set the options to default values.
  43. //
  44. //  Return Value:
  45. //      None.
  46. //
  47. proc setOptionVars(int $forceFactorySettings)
  48. {
  49.     // there are no optionVars that apply
  50. }
  51.  
  52. //
  53. //  Procedure Name:
  54. //      blendShapeRemoveSetup
  55. //
  56. //  Description:
  57. //        Update the state of the option box UI to reflect the option values.
  58. //
  59. //  Input Arguments:
  60. //      parent               - Top level parent layout of the option box UI.
  61. //                             Required so that UI object names can be 
  62. //                             successfully resolved.
  63. //
  64. //    forceFactorySettings - Whether the option values should be set to
  65. //                             default values.
  66. //
  67. //  Return Value:
  68. //      None.
  69. //
  70. global proc blendShapeRemoveSetup(string $parent, int $forceFactorySettings)
  71. {
  72.     // Retrieve the option settings
  73.  
  74.     setOptionVars ($forceFactorySettings);
  75.  
  76.     setParent $parent;
  77.  
  78.     // Query the optionVar's and set the values into the controls
  79.  
  80.     // node and target names are not options since it is unlikely the
  81.     // user would want them to persist past one session
  82.     //
  83.     checkBoxGrp -edit -v1 0 bsSpec;
  84.     checkBoxGrp -edit -v1 0 bstSpec;
  85.     textFieldGrp -e -tx "" bsNode;
  86.     textFieldGrp -e -tx "" bstNode;
  87.     optionMenuGrp -e -enable 0 bsList;
  88.     textFieldGrp -e -enable 0 bsNode;    
  89. }
  90.  
  91. //
  92. //  Procedure Name:
  93. //      blendShapeRemoveCallback
  94. //
  95. //  Description:
  96. //        Update the option values with the current state of the option box UI.
  97. //
  98. //  Input Arguments:
  99. //      parent - Top level parent layout of the option box UI.  Required so
  100. //               that UI object names can be successfully resolved.
  101. //
  102. //    doIt   - Whether the command should execute.
  103. //
  104. //  Return Value:
  105. //      None.
  106. //
  107. global proc blendShapeRemoveCallback(string $parent, int $doIt)
  108. {
  109.     setParent $parent;
  110.  
  111.     // Set the optionVar's from the control values, and then perform the
  112.     // command
  113.     //
  114.     if ($doIt) {
  115.         performBlendShapeRemove 0; 
  116.         addToRecentCommandQueue "performBlendShapeRemove 0" "BlendShapeRemove";
  117.     }
  118. }
  119.  
  120. //
  121. //  Procedure Name:
  122. //      blendShapeRemoveOptions
  123. //
  124. //  Description:
  125. //        Construct the option box UI.  Involves accessing the standard option
  126. //        box and customizing the UI accordingly.
  127. //
  128. //  Input Arguments:
  129. //      None.
  130. //
  131. //  Return Value:
  132. //      None.
  133. //
  134. proc blendShapeRemoveOptions()
  135. {
  136.     //    Name of the command for this option box.
  137.     //
  138.     string $commandName = "blendShapeRemove";
  139.  
  140.     //    Build the option box actions.
  141.     //
  142.     string $callback = ($commandName + "Callback");
  143.     string $setup = ($commandName + "Setup");
  144.  
  145.     //    STEP 1:  Get the option box.
  146.     //    ============================
  147.     //
  148.     //    The value returned is the name of the layout to be used as
  149.     //    the parent for the option box UI.
  150.     //
  151.     string $layout = getOptionBox();
  152.     setParent $layout;
  153.     
  154.     //    STEP 2:  Pass the command name to the option box.
  155.     //    =================================================
  156.     //
  157.     //    Any default option box behaviour based on the command name is set 
  158.     //    up with this call.  For example, updating the 'Help' menu item with
  159.     //    the name of the command.
  160.     //
  161.     setOptionBoxCommandName("blendShape");
  162.     
  163.     //    STEP 3:  Activate the default UI template.
  164.     //    ==========================================
  165.     //
  166.     //    Activate the default UI template so that the layout of this 
  167.     //    option box is consistent with the layout of the rest of the 
  168.     //    application.
  169.     //
  170.     setUITemplate -pushTemplate DefaultTemplate;
  171.  
  172.     //    STEP 4: Create option box contents.
  173.     //    ===================================
  174.     //    
  175.     //    This, of course, will vary from option box to option box.    
  176.     
  177.     //    Turn on the wait cursor.
  178.     //
  179.     waitCursor -state 1;
  180.  
  181.     tabLayout -tabsVisible 0 -scrollable 1;
  182.     
  183.     string $parent = `columnLayout -adjustableColumn 1`;
  184.     
  185.     checkBoxGrp    
  186.         -numberOfCheckBoxes 1
  187.         -label "Specify Node"
  188.         -label1 ""
  189.         -v1 0 
  190.         -on1 "specifyBlendShapeCallback 1"
  191.          -ofc "specifyBlendShapeCallback 0"
  192.         bsSpec;
  193.  
  194.     textFieldGrp -enable 0 -label "BlendShape Node" -tx "" bsNode;
  195.     // Create an option menu listing existing blendShapes
  196.     //
  197.     optionMenuGrp -enable 0 -l "Existing Nodes"
  198.         -cc "textFieldGrp -e -tx `optionMenuGrp -q -v bsList` bsNode" bsList;
  199.  
  200.     // add all the blendShapes to the menu
  201.     //
  202.     int $pp;
  203.     string $bnArray[];
  204.     $bnArray = `ls -type blendShape`;
  205.     int $bnCount = size($bnArray);
  206.     if ($bnCount > 0) {
  207.         for ($pp = 0; $pp < $bnCount; $pp++)
  208.         {
  209.             menuItem -l $bnArray[$pp];
  210.         }
  211.     } else {
  212.         menuItem -l "No Blend Shape Selected";
  213.     }
  214.  
  215.     separator -w 1000;
  216.     
  217.     checkBoxGrp    
  218.         -numberOfCheckBoxes 1
  219.         -label "Specify Target"
  220.         -label1 ""
  221.         -v1 0 
  222.         -on1 "textFieldGrp -e -enable 1 bstNode"
  223.          -offCommand "textFieldGrp -e -enable 0 bstNode"
  224.         bstSpec;
  225.  
  226.     textFieldGrp -enable 0 -label "Target Name" -tx "" bstNode;
  227.     separator -w 1000;
  228.  
  229.     //    Turn off the wait cursor.
  230.     //
  231.     waitCursor -state 0;
  232.     
  233.     //    Step 5: Deactivate the default UI template.
  234.     //    ===========================================
  235.     //
  236.     setUITemplate -popTemplate;
  237.  
  238.     //    Step 6: Customize the buttons.  
  239.     //    ==============================
  240.     //
  241.     //    Provide more descriptive labels for the buttons.  This is not 
  242.     //    necessary, but in some cases, for example, a button labelled 
  243.     //    'Create' may be more meaningful to the user than one labelled
  244.     //    'Apply'.
  245.     //
  246.     //    Disable those buttons that are not applicable to the option box.
  247.     //
  248.     //    Attach actions to those buttons that are applicable to the option
  249.     //    box.  Note that the 'Close' button has a default action attached 
  250.     //    to it that will hide the window.  If a a custom action is
  251.     //    attached to the 'Close' button then be sure to call the 'hide the
  252.     //    option box' procedure within the custom action so that the option
  253.     //    box is hidden properly.
  254.  
  255.     //    'Apply' button.
  256.     //
  257.     string $applyBtn = getOptionBoxApplyBtn();
  258.     button -edit
  259.         -command ($callback + " " + $parent + " " + 1)
  260.         $applyBtn;
  261.  
  262.     //    'Save' button.
  263.     //
  264.     string $saveBtn = getOptionBoxSaveBtn();
  265.     button -edit 
  266.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  267.         $saveBtn;
  268.  
  269.     //    'Reset' button.
  270.     //
  271.     string $resetBtn = getOptionBoxResetBtn();
  272.     button -edit 
  273.         -command ($setup + " " + $parent + " " + 1)
  274.         $resetBtn;
  275.  
  276.     //    Step 7: Set the option box title.
  277.     //    =================================
  278.     //
  279.     setOptionBoxTitle("Remove Blend Shape Target Options"); 
  280.  
  281.     //    Step 8: Customize the 'Help' menu item text.
  282.     //    ============================================
  283.     //
  284.     setOptionBoxHelpTag( "EditBlendShapeRemove" );
  285.  
  286.     //    Step 9: Set the current values of the option box.
  287.     //    =================================================
  288.     //
  289.     eval (($setup + " " + $parent + " " + 0));    
  290.     
  291.     //    Step 10: Show the option box.
  292.     //    =============================
  293.     //
  294.     showOptionBox();
  295. }
  296.  
  297. //
  298. //  Procedure Name:
  299. //      blendShapeRemoveHelp
  300. //
  301. //  Description:
  302. //        Return a short description about this command.
  303. //
  304. //  Input Arguments:
  305. //      None.
  306. //
  307. //  Return Value:
  308. //      string.
  309. //
  310. proc string blendShapeRemoveHelp()
  311. {
  312.  
  313.     return 
  314.     "  Command: blendShapeRemove";
  315. }
  316.  
  317. //
  318. //  Procedure Name:
  319. //      assembleCmd
  320. //
  321. //  Description:
  322. //        Construct the command that will apply the option box values.
  323. //
  324. //  Input Arguments:
  325. //      None.
  326. //
  327. proc string assembleCmd()
  328. {
  329.     string $cmd;
  330.     
  331.     setOptionVars(false);
  332.  
  333.     $cmd = "doBlendShape";
  334.  
  335.     //    This is remove mode = 3
  336.  
  337.     int $radio = 3;
  338.  
  339.     int $bsp=0;
  340.     if (`checkBoxGrp -exists bsSpec`) {
  341.         $bsp = `checkBoxGrp -query -v1 bsSpec`;
  342.     }
  343.     
  344.     string $bsn="\"\"";
  345.     if (`textFieldGrp -exists bsNode`) {
  346.         $bsn = `textFieldGrp -query -tx bsNode`;
  347.         if ($bsn=="") $bsn="\"\"";
  348.     }
  349.     
  350.     int $bstp=0;
  351.     if (`checkBoxGrp -exists bstSpec`) {
  352.         $bstp = `checkBoxGrp -query -v1 bstSpec`;
  353.     }
  354.     
  355.     string $bstn="\"\"";
  356.     if (`textFieldGrp -exists bstNode`) {
  357.         $bstn = `textFieldGrp -query -tx bstNode`;
  358.         if ($bstn=="") $bstn="\"\"";
  359.     }
  360.  
  361.     // the topology check, delete targets, wt and tween arguments are
  362.     // not applicable to blendShapeRemove
  363.     //
  364.     int $top = 0;
  365.     int $deltgt = 0;
  366.     int $tween = 0;
  367.     float $bstw=0;
  368.  
  369.     $cmd += (" " + $radio + " " + $tween + " " + $top + " " 
  370.              + $bsp + " " + $bsn + " "  + $bstp + " " + $bstn + " " + $bstw
  371.         + " " + $deltgt);
  372.     
  373.     return $cmd;
  374. }
  375.  
  376. //
  377. //  Procedure Name:
  378. //      performBlendShapeRemove
  379. //
  380. //  Description:
  381. //        Perform the optionBoxExample1 command using the corresponding 
  382. //        option values.  This procedure will also show the option box
  383. //        window if necessary as well as construct the command string
  384. //        that will invoke the optionBoxExample1 command with the current
  385. //        option box values.
  386. //
  387. //  Input Arguments:
  388. //      0 - Execute the command.
  389. //      1 - Show the option box dialog.
  390. //      2 - Return the command.
  391. //
  392. global proc string performBlendShapeRemove(int $action)
  393. {
  394.     string $cmd = "";
  395.  
  396.     switch ($action) {
  397.  
  398.         //    Execute the command.
  399.         //
  400.         case 0:
  401.             //    Get the command.
  402.             //
  403.             $cmd = `assembleCmd`;
  404.  
  405.             //    Execute the command with the option settings.
  406.             //
  407.             eval($cmd);
  408.  
  409.             break;
  410.  
  411.         //    Show the option box.
  412.         //
  413.         case 1:
  414.             blendShapeRemoveOptions;
  415.             break;
  416.  
  417.         //    Return the command string.
  418.         //
  419.         case 2:
  420.             //    Get the command.
  421.             //
  422.             $cmd = `assembleCmd`;
  423.             break;
  424.     }
  425.     return $cmd;
  426. }
  427.  
  428.